<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
    <meta name="author" content="Coderthemes">

    <link rel="stylesheet" href="/adminstatic/base/base.css"/>
    <script src="/adminstatic/base/baseCss.js"></script>

    <style type="text/css">
        html, body {
            background: #fff;
        }

        .layui-input-block {
            margin-left: 0;
        }
    </style>
</head>

<body class="fixed-left">

<!-- Begin page -->
<div id="wrapper">

    <div class="container">

        <div class="panel panel-default" style="box-shadow: none">
            <div class="panel-body">
                <div id="inputForm" class="form-horizontal">
                    <input type="hidden" name="id" value="<%= id %>"/>
                    <div class="row" style="padding:0 20px">
                        <div class="form-group">
                            <div class="col-xs-12 col-md-4 ">
                                <label ><small class="notNullFlag">*</small> 当前密码</label>
                                <input class="form-control" type="password" id="oldPassword" name="oldPassword"
                                       value="" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-xs-12 col-md-4 ">
                                <label ><small class="notNullFlag">*</small> 新密码</label>
                                <input class="form-control" type="password" id="newPassword" name="newPassword"
                                       value=""
                                       required>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-xs-12 col-md-4 ">
                                <label ><small class="notNullFlag">*</small> 确认密码</label>
                                <input class="form-control" type="password" id="confirmPassword" name="confirmPassword"
                                       value=""
                                       required>
                            </div>
                        </div>


                    </div>

                </div>
                <div id="actions">
                    <button type="button" class="layui-btn layui-btn-normal" id="submitBtn">保存</button>
                    <button type="button" class="layui-btn layui-btn-primary" onclick="closeIframe()">取消</button>
                </div>
            </div><!-- panel-body -->
        </div> <!-- panel -->

    </div> <!-- container -->

</div>
<!-- END wrapper -->

<script src="/adminstatic/base/base.js"></script>
<script type="text/javascript">

    $("#submitBtn").click(function () {
        var id = $("input[name='id']").val();
        console.log(id)
        var oldPassword = $("input[name='oldPassword']").val();
        if (!vaildeParam(oldPassword)) {
            layer.msg("当前密码不能为空",{icon:5});
            return;
        }

        var newPassword = $("input[name='newPassword']").val();

        if (!vaildeParam(newPassword)) {
            layer.msg("密码不能为空",{icon:5});
            return;
        }

        var confirmPassword = $("input[name='confirmPassword']").val();
        if (!vaildeParam(confirmPassword)) {
            layer.msg("确认密码不能为空",{icon:5});
            return;
        }

        if(newPassword != confirmPassword){
            layer.msg("两次密码不正确",{icon:5});
            return;
        }

        var api = '/admin/changePassword';
        var data = {
            "id": id,
            "oldPassword": oldPassword,
            "newPassword": newPassword
        }

        postJSON(api, data, function (res) {
            cleanSuccess(res)

        })

    })
</script>
</body>
</html>